package com.lmx.repoDomain.tmodel;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 乡镇表
 */
@JsonApiResource(type = "town")
@Table(name = "t_s_town")
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Town extends BaseEntity {

	private String remark;// 备注

	private String name;

	private County county;
	// private List<Bed> beds;
	//
	// @Transient
	// @JsonApiToMany
	// @JsonApiIncludeByDefault
	// public List<Bed> getBeds() {
	// return beds;
	// }
	//
	// public void setBeds(List<Bed> beds) {
	// this.beds = beds;
	// }

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "county_id", foreignKey = @ForeignKey(name = "null"))
	public County getCounty() {
		return county;
	}

	public void setCounty(County county) {
		this.county = county;
	}

	@Column(name = "town_name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Town() {
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
}
